package com.ouc.openplatform.zykt.orderManage.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ouc.openplatform.common.TestDataToTestDataVO;
import com.ouc.openplatform.pojo.EUDataGridResult;
import com.ouc.openplatform.zykt.orderManage.dao.CS_TestDataDao;
import com.ouc.openplatform.zykt.orderManage.model.CS_TestData;
import com.ouc.openplatform.zykt.orderManage.model.CS_TestDataVo;
import com.ouc.openplatform.zykt.orderManage.service.CS_TestDataService;

public class CS_TestDataServiceImpl implements CS_TestDataService{

	private CS_TestDataDao testDataDao;
	
	private TestDataToTestDataVO testDataToTestDataVO;
	
	public TestDataToTestDataVO getTestDataToTestDataVO() {
		return testDataToTestDataVO;
	}

	public void setTestDataToTestDataVO(TestDataToTestDataVO testDataToTestDataVO) {
		this.testDataToTestDataVO = testDataToTestDataVO;
	}

	public CS_TestDataDao getTestDataDao() {
		return testDataDao;
	}

	public void setTestDataDao(CS_TestDataDao testDataDao) {
		this.testDataDao = testDataDao;
	}

	@Override
	public EUDataGridResult getAllTestData(String primarykey, int page, int rows) {
		//分页处理
		PageHelper.startPage(page, rows);
		List<CS_TestData> testDataList = testDataDao.getAllTestData(primarykey);
		List<CS_TestDataVo> testDataVoList=new ArrayList<CS_TestDataVo>();
		for (int i = 0; i < testDataList.size(); i++) {
			CS_TestDataVo testDataVo=new CS_TestDataVo();
			testDataVo=testDataToTestDataVO.TestDataToTestDataVo(testDataList.get(i));
			testDataVoList.add(testDataVo);
		}
		//创建一个返回值对象
		EUDataGridResult result = new EUDataGridResult();
		result.setRows(testDataVoList);
		//取记录总条数
		PageInfo<CS_TestData> pageInfo = new PageInfo<CS_TestData>(testDataList);
		result.setTotal(pageInfo.getTotal());
		return result;
	}

	/*@Override
	public List<CS_TestData> getAllTestData(String primarykey) {
		List<CS_TestData> testDataList = testDataDao.getAllTestData(primarykey);
		return testDataList;
	}*/
	
}
